import PermissionButton from '@/components/BizButtons/PermissionButton';
import { UseActionControlReturnType } from '@/hooks/useActionControl';
import { EyeOutlined } from '@ant-design/icons';
import React from 'react';

interface TableRowViewButtonProps {
  actionControl: UseActionControlReturnType;
  record: Record<string, any>;
  /** 所需权限,eg: ['monitor:online:forceLogout'], 传 [] 的视作不需要权限, 默认不需要权限 */
  permissionsRequired?: string[];
  /** 按钮的文字, 默认为空 即只显示图标 */
  buttonText?: string;
}

const TableRowViewButton: React.FC<TableRowViewButtonProps> = ({
  actionControl,
  record,
  permissionsRequired = [],
  buttonText = '',
}) => {
  return (
    <PermissionButton
      permissionsRequired={permissionsRequired}
      icon={<EyeOutlined />}
      type={'link'}
      onClick={() => actionControl.actions.openViewModal(record)}
    >
      {buttonText}
    </PermissionButton>
  );
};

export default TableRowViewButton;
